package cn.iocoder.mall.product.application.controller.users;

import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.utils.common.system.util.JwtUtil;
import cn.iocoder.mall.product.api.ProductSpuCollectionService;
import cn.iocoder.mall.product.application.vo.users.ProductCollectionVO;
import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import static cn.iocoder.common.framework.vo.CommonResult.success;


@RestController
@RequestMapping("/users/spu")
@Api("商品收藏")
public class UsersProductSpuCollectionController {

    @Reference(validation = "true", version = "${dubbo.provider.ProductSpuCollectionService.version}")
    private ProductSpuCollectionService productSpuCollectionService;

    @PostMapping("/collection")
    @ApiOperation("商品收藏")
    @RequiresLogin
    public CommonResult<Boolean> productSpuCollection(@RequestBody ProductCollectionVO vo) {
        return success(productSpuCollectionService.productSpuCollection(vo.getSpuId(), vo.getHasCollectionType(), JwtUtil.getUserIdByToken()));
    }
}
